package com.demo.widget.meis;


import com.demo.widget.ResourceTable;
import com.meis.widget.MeiScrollParallaxView;
import ohos.agp.components.*;

import java.util.ArrayList;
import java.util.List;

/**
 * desc:
 * author: wens
 * date: 2018/4/30.
 */
public class MeiScrollParallaxAdapter extends BaseItemProvider {
    private List<String> list = new ArrayList<>();

    public MeiScrollParallaxAdapter(List<String> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        return list == null ? 0 : list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public Component getComponent(int i, Component component, ComponentContainer componentContainer) {
        component = LayoutScatter.getInstance(componentContainer.getContext())
                .parse(ResourceTable.Layout_scroll_parallax_item, componentContainer, false);
        MeiScrollParallaxView meiScrollParallaxView =
                (MeiScrollParallaxView) component.findComponentById(ResourceTable.Id_view);
        if (meiScrollParallaxView.getRootListContainer() == null) {
            meiScrollParallaxView.setListContainer((ListContainer) componentContainer);
        }
        return component;
    }


}
